package com.zmn.plat.admin.controller.product.guarantee;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.plat.model.entity.product.ServProduct;
import com.zmn.plat.model.entity.product.guarantee.ProductGuarantee;

/**
 * 产品保障管理
 *
 * @author linfeng
 *
 * @since 2020-03-17 10:16:02
 */
@Controller
@RequestMapping("/showProduct/guarantee/")
public class ShowProductGuaranteeListController extends ShowProductGuaranteeBaseController {

    /**
     * 详情
     * 
     * @author linfeng
     * @param productId
     * @since 2020-03-17 10:16:02
     */
    @RequestMapping("detail")
    @RequiresPermissions("/showProduct/guarantee/detail.action")
    public ModelAndView detail(@RequestParam(value = "productId", defaultValue = "0") Integer productId) {
        ProductGuarantee productGuarantee = productGuaranteeService.findByProductId(productId);
        if (productGuarantee == null) {
            productGuarantee = new ProductGuarantee();
        }

        ServProduct servProduct = productId > 0 ? servProductService.findByKey(productId) : new ServProduct();
        ModelAndView mav = new ModelAndView("product/guarantee/detail");
        mav.addObject("servProductVO", servProduct);
        mav.addObject("productGuarantee", productGuarantee);
        mav.addObject("flag", 4);

        return mav;
    }

}
